package com.cmict.data.system.dal.mysql.oa;

import com.cmict.data.framework.common.pojo.PageResult;
import com.cmict.data.framework.mybatis.core.mapper.BaseMapperX;
import com.cmict.data.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.cmict.data.system.controller.admin.oa.vo.ScheduleManagementCalendarReqVO;
import com.cmict.data.system.controller.admin.oa.vo.ScheduleManagementNoPushReqVO;
import com.cmict.data.system.controller.admin.oa.vo.ScheduleManagementPageReqVO;
import com.cmict.data.system.dal.dataobject.oa.ScheduleManagementDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


import java.util.List;
import java.util.Set;

@Mapper
public interface ScheduleManagementMapper extends BaseMapperX<ScheduleManagementDO> {

    default List<ScheduleManagementDO> selectList(ScheduleManagementCalendarReqVO reqVO){
        return selectList(new LambdaQueryWrapperX<ScheduleManagementDO>()
                .eq(ScheduleManagementDO::getCreator,reqVO.getCreator())
                .ge(ScheduleManagementDO::getStartTime,reqVO.getStartTime())
                .le(ScheduleManagementDO::getStartTime,reqVO.getEndTime()));
    }

    default PageResult<ScheduleManagementDO> selectPage(ScheduleManagementPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ScheduleManagementDO>()
                .likeIfPresent(ScheduleManagementDO::getRemindContent,reqVO.getRemindContent())
                .eq(ScheduleManagementDO::getCreator,reqVO.getCreator())
                .eqIfPresent(ScheduleManagementDO::getStatus,reqVO.getStatus())
                .orderByDesc(ScheduleManagementDO::getUpdateTime));
    }

    default List<ScheduleManagementDO> selectListNoPush(ScheduleManagementNoPushReqVO reqVO){
        return selectList(new LambdaQueryWrapperX<ScheduleManagementDO>()
                .inIfPresent(ScheduleManagementDO::getStatus,reqVO.getStatus())
                .eq(ScheduleManagementDO::getCreator,reqVO.getCreator())
                .le(ScheduleManagementDO::getSendTime,reqVO.getSendTime()));
    }

    default List<ScheduleManagementDO> selectListNoPushAll(Set<Integer> status,String sendTime){
        return selectList(new LambdaQueryWrapperX<ScheduleManagementDO>()
                .inIfPresent(ScheduleManagementDO::getStatus,status)
                .le(ScheduleManagementDO::getSendTime,sendTime)
                .orderByAsc(ScheduleManagementDO::getRemindSet));
    }
}
